import express from "express"
import expressjoi from "../utils/expressjoi.js"
import multer from "multer"
import { addArticle, getArticle } from "../router_handler/article.js"
import { addArticle_schema } from "../schema/schema_article.js"
// 创建multer实例,设置文件存放路径,以当前项目为路径，自动生成文件夹
// 配置multer为内存存储
const storage = multer.memoryStorage()

// const upload = multer({dest:'uploads/'})
const upload = multer({ storage })
// 文章的相关接口
const router = express.Router()
// 新增文章接口
router.post(
    "/add",
    upload.single("cover_img"),
    expressjoi(addArticle_schema),
    addArticle
)
// 查询文章列表接口
router.get('/get', getArticle)
export default router
